package com.yunxi.service.localService.impl.sto;

import com.yunxi.core.service.ServiceImplPlus;
import com.yunxi.dao.sto.StoCarrierMapper;
import com.yunxi.dealer.pojo.PartnerVO;
import com.yunxi.model.sto.StoCarrier;
import com.yunxi.service.localService.sto.StoCarrierService;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 承运商信息 服务实现类
 * </p>
 *
 * @author caoYong
 * @since 2019-05-14
 */
@Service
public class StoCarrierServiceImpl extends ServiceImplPlus<StoCarrierMapper, StoCarrier> implements StoCarrierService {

    @Override
    public void delAndReset(List<String> list, Integer isDel,String userId) {
        for (String id:list){
            StoCarrier stoCarrier = baseMapper.selectById(id);
            stoCarrier.setIsDel(isDel);
            stoCarrier.setUpdateBy(userId);
            baseMapper.updateById(stoCarrier);
        }
    }

    @Override
    public void frozenAndReset(List<String> list, Integer isFrozen,String userId) {
        for (String id:list){
            StoCarrier stoCarrier = baseMapper.selectById(id);
            stoCarrier.setIsFrozen(isFrozen);
            stoCarrier.setUpdateBy(userId);
            baseMapper.updateById(stoCarrier);
        }
    }

    @Override
    public String getDictNamesByKey(String pid, List list) {
        Map<String, Object> map = new HashMap();
        map.put("PID",pid);
        map.put("LIST",list);
        return baseMapper.getDictNamesByKey(map);
    }

    /**
     * 根据特征码查询名称
     * @param nodeCode
     * @return
     * @throws Exception
     */
    @Override
    public String queryNodeNameByCode(String nodeCode) throws Exception {
        return baseMapper.queryNodeNameByCode(nodeCode);
    }

    @Override
    public String queryNodeCodeByCode(String nodeCode) throws Exception {
        return baseMapper.queryNodeCodeByCode(nodeCode);
    }

    @Override
    public String queryOutColorName(String colorCode) throws Exception {
        return baseMapper.queryOutColorName(colorCode);
    }

    @Override
    public String queryInColorName(String colorCode) throws Exception {
        return baseMapper.queryInColorName(colorCode);
    }

    /**
     * 根据渠道商代码查询名称
     * @param partnerCode
     * @return
     * @throws Exception
     */
    @Override
    public PartnerVO queryPartnerNameByCode(String partnerCode) throws Exception {
        return baseMapper.queryPartnerNameByCode(partnerCode);
    }
}
